<%-- 
    Document   : CheckOut
    Created on : May 17, 2012, 1:36:20 PM
    Author     : Alex

    CheckOut, where we find out what pay is due to the till.
--%>

<%@page import="store.ShopInventory"%>
<%@page import="beans.Customer, java.util.*"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Check Out</title>
    </head>
    <body>
        <h2>Thank you, <%=Customer.getName()%>, for shopping
            at this Store.</h2>

        <%
            Hashtable<Integer, Float> items = Customer.getCartItems();
            Enumeration<Integer> keys = items.keys();

            float totalPrice = 0.00f;

            out.println("<table>");
            out.println("<tr>");
            out.println("<td>Quantity</td>");
            out.println("<td>Item</td>");
            out.println("<td>Price</td>");
            out.println("<td>Total</td>");
            out.println("</tr>");

            for (int g = 0; g < items.size(); g++) {
                Integer thing = keys.nextElement();
                out.println("<tr>");
                out.println("<td>" + items.get(thing) + "</td>");
                out.println("<td>" + ShopInventory.getShopItem(thing)
                        .getName() + "</td>");
                out.println("<td>" + ShopInventory.getShopItem(thing)
                        .getPrice() + "</td>");
                out.println("<td>" + (items.get(thing) * 
                        ShopInventory.getShopItem(thing).getPrice())
                        + "</td>");
                out.println("</tr>");
                totalPrice += (items.get(thing) * 
                        ShopInventory.getShopItem(thing).getPrice());
            }
            out.println("</table>");
            out.println("<br/>");
            
            out.println("Your total is $" + totalPrice + "<br/>");
            out.println("Items will be shipped to:");
            out.println(Customer.getAddress());
            out.println("<h2>We accept money and gold</h2>");
        %>


    </body>
</html>
